package die_error;

require Exporter;


our @ISA = qw(Exporter);
our $VERSION = 1.00;
our @EXPORT = qw(die_error open_or_die sysopen_or_die warn_error print_warning mkdir_or_die);

use strict;
use warnings;
use Carp;
use wrap_text;

sub die_error($)
{
	croak("\nError:\n".wrap_text($_[0])."\n\n");
}

sub warn_error($)
{
	carp("\nWarning:\n".wrap_text($_[0])."\n\n");
}

sub print_warning($)
{
	print STDERR "\n\tWarning:\n".wrap_text($_[0], "\t    "). "\n\n";
}

sub open_or_die(\*$)
{
	my ($file_handle, $file_name) = @_;
	open $file_handle, "$file_name" or 
			die_error ("Can't open $file_name. $!");;

}


sub sysopen_or_die(\*$$)
{
	my ($file_handle, $file_name, $mode) = @_;
	sysopen $file_handle, "$file_name", $mode or 
			die_error ("Can't open $file_name. $!");;

}



sub mkdir_or_die($)
{
	my ($dir_name) = @_;
    return if (-d $dir_name);

    mkdir $dir_name or die_error("Could not make directory $dir_name. $!");
}

